const path = require('path')
const webpack = require('webpack')

function resolve (dir) {
  return path.join(__dirname, dir)
}

// vue.config.js
module.exports = {
	//简单配置webpack,此配置将会被 webpack-merge 合并入最终的 webpack 配置	
	configureWebpack: {
		plugins: [
			// 忽略moment.js的所有区域设置文件
			new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
		]
	},
	//chainWebpack做高级配置 配置webpack
	chainWebpack: (config) => {
		//配置别名
		config.resolve.alias
			.set('@$', resolve('src'))
			.set('@api', resolve('src/api'))
			.set('@assets', resolve('src/assets'))
			.set('@comp', resolve('src/components'))
			.set('@views', resolve('src/views'))
			.set('@layout', resolve('src/layout'))
			.set('@static', resolve('src/static'))
	
		//配置svg规则
		config.module
			.rule('svg')
			.exclude.add(resolve('src/icons'))
			.end()
		config.module
			.rule('icons')
			.test(/\.svg$/)
			.include.add(resolve('src/icons'))
			.end()
			.use('svg-sprite-loader')
			.loader('svg-sprite-loader')
			.options({
				symbolId: 'icon-[name]'
			})
			.end()
	},
	//css相关配置
	css: {
		loaderOptions: {
			less: {
				modifyVars: {},
				javascriptEnabled: true
			}
		}
	},

	//配置开发环境,端口,代理等等
	devServer: {
		// development server port 8000
		port: 8000,
		proxy: {
		'/api': {
			target: 'http://localhost:8760',
			ws: false,
			changeOrigin: true,
			pathRewrite:{
				'^/api':''
			}
		},
	}
  },

  // 在生产中禁用源映射
  productionSourceMap: false,
  lintOnSave: undefined,
  // babel-loader no-ignore node_modules/*
  transpileDependencies: []
}
